package com.yz.test.okhttp.service;

import com.yz.test.okhttp.demo.GetStaticDemo;
import com.yz.test.okhttp.util.SleepUtil;
import org.springframework.stereotype.Service;

import java.util.Random;

@Service
public class OptionService {

    public static final String XXXX="getStaticXXX";

    public void trace(){
        SleepUtil.sleep1s();
        SleepUtil.sleep4s();
        SleepUtil.sleep2s();
    }

    public void stack(){
        System.out.println("stack");
    }

    public void getStatic(){
        System.out.println(XXXX);
    }

    public void monitor() throws Exception{
        int i = new Random().nextInt();
        if (i%4==2){
            throw new RuntimeException("monitor exception ");
        }
    }

    public Integer watch(String p,String l) throws Exception{
        int i = new Random().nextInt();
        if (i%4==2){
            throw new RuntimeException("monitor exception ");
        }
        return i;
    }


}
